

***********
*MAIN TEXT*
***********



**Table 1: Effect of gender on the most-voted party attaining the mayor's office

use main_short.dta, clear

quietly estimates clear

*All parties
quietly rdrobust mayorwinner fwl if absoluta==0
	quietly estimates store main_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar enl = e(N_h_l)
	quietly estadd scalar enr = e(N_h_r)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03
	quietly estimates store main_third
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar enl = e(N_h_l)
	quietly estadd scalar enr = e(N_h_r)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties & gender-mixed
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & gendermixed==1
	quietly estimates store main_third_gm
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar enl = e(N_h_l)
	quietly estadd scalar enr = e(N_h_r)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Table
esttab main_all main_third main_third_gm, replace nonumbers nogaps ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "Female leader") collabels("" "") ///
  stats(pcl bwcl en enl enr n , labels("P-value" "Bandwidth" "Effective N" "Eff. N (left)" "Eff. N (right)" "N") fmt(%9.3f %9.3f 0 0)) ///
  mlabels("All parties" "No 3rd parties" "No 3rd parties \& gender-mixed") ///
  addnotes(Standard errors in parentheses)


  
  
**Figure 1: RD plots on the effect of gender on winning the mayor's office

use main_short.dta, clear

*Left plot
quietly rdrobust mayorwinner fwl if absoluta==0
rdplot mayorwinner fwl if absoluta==0 & inrange(fwl,-e(h_l),e(h_r)), ///
   graph_options(legend(off) xlabel(-.10(.01).10) ylabel(0(.1)1) ///
   ytitle("Pr(Mayor for the Most Voted Party = 1)") xtitle("Woman's Margin of Victory", height(5))) ///
   scheme(plotplain)

*Right plot
quietly rdrobust mayorwinner fwl if absoluta==0
rdplot mayorwinner fwl if absoluta==0 & inrange(fwl,-e(h_l),e(h_r)), ///
   binselect(esmv) kernel(triangular) h(`e(h_l)' `e(h_r)') p(1) ///
   graph_options(legend(off) xlabel(-.10(.01).10) ylabel(0(.1)1) ///
   ytitle("Pr(Mayor for the Most Voted Party = 1)") xtitle("Woman's Margin of Victory", height(5))) ///
   scheme(plotplain)


   

**Table 2: Effect of gender on government participation

use main_short.dta, clear

quietly estimates clear

*1st in gov.
quietly rdrobust firstgov fwl if absoluta==0, h(.091)
	quietly estimates store firstgov_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*2nd in gov
quietly rdrobust runnerupgov fwl if absoluta==0, h(.091)
	quietly estimates store runnerupgov_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*3rd+ in gov.
quietly rdrobust thirdmoregov fwl if absoluta==0, h(.091)
	quietly estimates store thirdmoregov_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Mayor 2nd
quietly rdrobust mayorsecond fwl if absoluta==0, h(.091)
	quietly estimates store mayorsecond_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Mayor 3rd+
quietly rdrobust mayorthirdormore fwl if absoluta==0, h(.091)
	quietly estimates store mayorthirdormore_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)
  
*Table
esttab firstgov_all runnerupgov_all thirdmoregov_all mayorsecond_all mayorthirdormore_all, replace nonumbers nogaps ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "Female leader") collabels("" "") ///
  stats(pcl bwcl en n, labels("P-value" "Bandwidth" "Effective N" "N") fmt(%9.3f %9.3f 0 0)) ///
  mlabels("1st in gov." "2nd in gov." "3rd+ in gov." "Mayor 2nd" "Mayor 3rd+") ///
  addnotes(Standard errors in parentheses)


  

**Table 3 [TRANSPOSED]: Discontinuities in pretreatment covariates (Local linear regression estimates)

use main_short.dta, clear

quietly estimates clear

*Most voted party average age
quietly rdrobust agefirst fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store pdiff1
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Most voted party average education level
quietly rdrobust edufirst fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store pdiff2
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Most voted party incumbent mayor
quietly rdrobust incumbent fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store pdiff3
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Most voted party left-right placement
quietly rdrobust ideology fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store pdiff4
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Most voted party = PP
quietly rdrobust pp fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store pdiff5
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Most voted party = PSOE
quietly rdrobust psoe fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store pdiff6
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Most voted party = Others
quietly rdrobust other fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store pdiff7
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Table
esttab pdiff*, replace nonumbers nogaps ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "RD Estimate") collabels("" "") ///
  stats(pcl en n, labels("P-value" "Effective N" "N") fmt(%9.3f 0 0)) ///
  mlabels("Average age of the most voted party" ///
  "Average education level of the most voted party" ///
  "Incumbent mayor party" ///
  "Left-right placement of the most voted party" ///
  "Most voted party = PP" ///
  "Most voted party = PSOE" ///
  "Most voted party = Others") ///
  addnotes(Bandwidth is the optimal in the main analyses: .091)





**********
*APPENDIX*
**********



**Figure A1: External validity check: Spain (2003-2007) and Western Europe (1945-1998)

*Top plot

use choice_data.dta, clear

quietly label var pc_cont_mostvoted "Largest Party"
quietly label var pc_seatshare "Seat Share"
quietly label var pc_seatshare_sq100 "Seat Share (sq.)"
quietly label var pc_minority "Minority Gov."
quietly label var pc_mwc "Minimal-Winning Coal."
quietly label var pc_nparties "N. of Parties in Gov."
quietly label var pc_incumb_cab_com "Incumbent Gov."
quietly label var pc_incumb_cab_ihi "Incumbent Gov."
quietly label var pc_incumb_pty "Incumbent Party"
quietly label var pc_incumb_mayor "Previous Mayoral Party"
quietly label var pc_wdistmedian "(Weighted) Distance to Median"

quietly clogit choice pc_cont_mostvoted pc_seatshare pc_seatshare_sq100 pc_minority pc_mwc pc_nparties pc_incumb_cab_ihi pc_incumb_pty pc_incumb_mayor pc_wdistmedian if absoluta==0 , group(formopp)
coefplot, xline(0,) xlabel(-2(.5)+3, labsize(small)) ylabel(, labsize(vsmall)) title("Determinants of Government Formation") subtitle("- Spanish Local Governments -", size(small)) ///
   scheme(plotplain)


*Bottom plot

use coaldata_BJPS_glasgowgolder2015.dta, clear

replace distance_median_weighted=distance_median_weighted*10

label var largest_party "Largest Party"
label var seatshare "Seat Share"
label var seatshare_sq "Seat Share (sq.)"
label var minor "Minority Gov."
label var minwin "Minimal-Winning Coal."
label var numparties "N. of Parties in Gov."
label var incumb_govt "Incumbent Gov."
label var incumb_parties "Incumbent Party"
label var prevpm "Previous PM Party"
label var distance_median_weighted "(Weighted) Distance to Median"

quietly clogit govt_coal largest_party seatshare seatshare_sq minor minwin numparties incumb_govt incumb_parties prevpm distance_median_weighted , group(formnum)
coefplot, xline(0,) xlabel(-2(.5)+3, labsize(small)) ylabel(, labsize(vsmall)) title("Determinants of Government Formation") subtitle("- West European National Governments -", size(small)) ///
   scheme(plotplain)




**Figure B1: Share of women in European national parliaments

use women_mps.dta, clear 

quietly{
	reshape long A, i(CountryCode) j(year)
	rename A sha_w_mps
}
twoway (line sha_w_mps year if CountryCode=="EUU", lpattern(dash) lwidth(medium) lcolor(gs10))  ///
	(line sha_w_mps year if CountryCode=="ESP", lpattern(solid) lwidth(medthick) lcolor(black)) ///
	(line sha_w_mps year if CountryCode=="DEU", lpattern(shortdash) lwidth(medium) lcolor(black))	///
	(line sha_w_mps year if CountryCode=="FRA", lpattern(dash_dot) lwidth(medium) lcolor(black))	///
	(line sha_w_mps year if CountryCode=="GBR", lpattern(longdash_dot) lwidth(medium) lcolor(black)) ///
	(line sha_w_mps year if CountryCode=="SWE", lpattern(shortdash_dot) lwidth(medium) lcolor(black)) ///
	(line sha_w_mps year if CountryCode=="ITA", lpattern(longdash) lwidth(medium) lcolor(black)), ///
	ylabel(0(10)50) ytitle("% of seats of women in national parliaments") xlabel(1996(2)2020) xtitle("") ///
	legend(label(1 "EU28") label(2 "Spain") label(3 "Germany") label(4 "France") label(5 "UK") label(6 "Sweden") label(7 "Italy") symxsize(*1.5)) ///
    scheme(plotplain)




*Figure B2: Share of councilors and mayors in European local institutions

use women_local.dta, clear 

quietly{
	gen position2=2 if _position =="MEMB_CNCL"
	replace position2=1 if _position=="PRES_CNCL"
}

*Left plot
twoway (line value time if position2==2 & country_code==0, lpattern(dash) lwidth(medium) lcolor(gs10)) ///
	(line value time if position2==2 & country_code==12, lpattern(solid) lwidth(medthick) lcolor(black))  ///
	(line value time if position2==2 & country_code==8, lpattern(shortdash) lwidth(medium) lcolor(black)) ///
	(line value time if position2==2 & country_code==14, lpattern(dash_dot) lwidth(medium) lcolor(black)) ///
	(line value time if position2==2 & country_code==37, lpattern(longdash_dot) lwidth(medium) lcolor(black)) ///
	(line value time if position2==2 & country_code==33, lpattern(shortdash_dot) lwidth(medium) lcolor(black)) ///
	(line value time if position2==2 & country_code==19, lpattern(longdash) lwidth(medium) lcolor(black)), ///
	ylabel(0(10)50) ytitle("% Female Councilors") xlabel(2010(2)2020) xtitle("") ///
	legend(label(1 "EU28") label(2 "Spain") label(3 "Germany") label(4 "France") label(5 "UK") label(6 "Sweden") label(7 "Italy") symxsize(*1.5)) ///
    scheme(plotplain)

*Right plot
twoway (line value time if position2==1 & country_code==0, lpattern(dash) lwidth(medium) lcolor(gs10)) ///
	(line value time if position2==1 & country_code==12, lpattern(solid) lwidth(medthick) lcolor(black))  ///
	(line value time if position2==1 & country_code==8, lpattern(shortdash) lwidth(medium) lcolor(black)) ///
	(line value time if position2==1 & country_code==14, lpattern(dash_dot) lwidth(medium) lcolor(black)) ///
	(line value time if position2==1 & country_code==37, lpattern(longdash_dot) lwidth(medium) lcolor(black)) ///
	(line value time if position2==1 & country_code==33, lpattern(shortdash_dot) lwidth(medium) lcolor(black)) ///
	(line value time if position2==1 & country_code==19, lpattern(longdash) lwidth(medium) lcolor(black)), ///
	ylabel(0(10)50) ytitle("% Female Mayors") xlabel(2010(2)2020) xtitle("") ///
	legend(label(1 "EU28") label(2 "Spain") label(3 "Germany") label(4 "France") label(5 "UK") label(6 "Sweden") label(7 "Italy") symxsize(*1.5)) ///
    scheme(plotplain)




**Figure B3: Share of female politicians by population, year, and party

use main_long.dta, clear

*Top-left plot
graph bar women_proportion elected_women_prop women_leader woman_mayor, ///
 blabel(name, position(inside) orientation(vertical) size(vsmall)) yvaroptions(relabel(1 "In party lists" 2 "Elected" 3 "Leaders" 4 "Mayors")) ///
 ylabel(0(.1).45) ytitle("Share of women", size(small)) title("All cases") ///
 yscale(range(-.04 .45)) ///
 legend(off) ///
 name(all, replace) ///
 scheme(plotplain)

*Top-right plot
graph bar women_proportion elected_women_prop women_leader woman_mayor, ///
 over(popgroup) blabel(name, position(inside) orientation(vertical) size(vsmall)) yvaroptions(relabel(1 "In party lists" 2 "Elected" 3 "Leaders" 4 "Mayors")) ///
 ylabel(0(.1).45) ytitle("Share of women", size(small)) title("By population") ///
 legend(off) ///
 name(pop, replace) ///
 scheme(plotplain)

*Bottom-left plot
graph bar women_proportion elected_women_prop women_leader woman_mayor, ///
 over(year) blabel(name, position(inside) orientation(vertical) size(vsmall)) yvaroptions(relabel(1 "In party lists" 2 "Elected" 3 "Leaders" 4 "Mayors")) ///
 ylabel(0(.1).45) ytitle("Share of women", size(small)) legend(off) title("By year") ///
 legend(off) ///
 name(year, replace) ///
 scheme(plotplain)

*Bottom-right plot
graph bar women_proportion elected_women_prop women_leader woman_mayor, ///
 over(party) blabel(name, position(inside) orientation(vertical) size(vsmall)) yvaroptions(relabel(1 "In party lists" 2 "Elected" 3 "Leaders" 4 "Mayors")) ///
 ylabel(0(.1).45) ytitle("Share of women", size(small)) legend(off) title("By party") ///
 legend(off) ///
 name(party, replace) ///
 scheme(plotplain)

*Graph
graph combine all pop year party, rows(2) ///
   scheme(plotplain)




**Table B1: Descriptive statistics by municipal council

use main_long.dta, clear

eststo clear

*Full sample
eststo bycouncil_all: quietly estpost summarize minority numparties enp total_seat turnout if mayor==1

*Minoirity
eststo bymincouncil_all: quietly estpost summarize numparties enp total_seat turnout if mayor==1 & minority==1

*Table
esttab bycouncil_all bymincouncil_all, replace nonumbers nogaps /// 
  cell(mean(fmt(%9.3f)) sd(par fmt(%9.3f))) ///
  mtitle("Full sample" "Minority") ///
  addnotes(Standard deviations in parentheses.)



**Table B2: Descriptive statistics by party

use main_long.dta, clear

eststo clear

*Full sample: All parties
eststo byparty_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe

*Full sample: Winner
eststo r1_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe if rank==1

*Full sample: Runner-up
eststo r2_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe if rank==2

*Full sample: Third+
eststo r3_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe if rank>=3 & rank!=.

*Minority: All parties
eststo byparty_min_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe if minority==1

*Minority: Winner
eststo r1_min_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe if rank==1 & minority==1

*Minority: Runner-up
eststo r2_min_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe if rank==2 & minority==1

*Minority: Third+
eststo r3_min_all: quietly estpost summarize women_leader women_proportion mean_age sseat svote pp psoe if rank>=3 & rank!=. & minority==1


*Table
esttab byparty_all r1_all r2_all r3_all byparty_min_all r1_min_all r2_min_all r3_min_all , replace nonumbers nogaps /// 
  cell(mean(fmt(%9.3f)) sd(par fmt(%9.3f))) ///
  mgroups("Full sample" "Minority", pattern(1 0 0 0 1 0 0 0) span) ///
  mtitle("All parties" "Winner" "Runner-up" "Third+" "All parties" "Winner" "Runner-up" "Third+") ///
  addnotes(Standard deviations in parentheses.)




**Table B3: Descriptive statistics of mayoral parties

use main_long.dta, clear

eststo clear

*Full sample
eststo descmayorrank_all: quietly estpost summarize mayor_vote mayorwinner mayorsecond mayorthirdormore if mayor==1

*Minority
eststo descmayorrankmin_all: quietly estpost summarize mayor_vote mayorwinner mayorsecond mayorthirdormore if mayor==1 & minority==1

*Table
esttab descmayorrank_all descmayorrankmin_all, replace nonumbers nogaps /// 
  cell(mean(fmt(%9.3f)) sd(par fmt(%9.3f))) ///
  mtitle("Full sample" "Minority") ///
  addnotes(Standard deviations in parentheses.)




**Figure B4: Mayor by party and party rank

use main_long.dta, clear

graph bar pp psoe other if mayor==1 & minority==1, over(mayorwho) blabel(name, position(inside) size(vsmall)) yvaroptions(relabel(1 "PP" 2 "PSOE" 3 "Other")) ///
 legend(off) ///
 ylabel(0(.1).75) ytitle("Share of cases", size(small)) ///
 scheme(plotplain)




*Table C1: Linear probability models of becoming the mayor party

use main_long.dta, clear

quietly estimates clear

*(1)
quietly reg mayor i.mostvoted if absoluta==0
	quietly estimates store lpm1

*(2)
quietly reg mayor i.mostvoted svote if absoluta==0
	quietly estimates store lpm2

*(3)
quietly reg mayor i.mostvoted##i.women_leader if absoluta==0
	quietly estimates store lpm3
  
*Table
esttab lpm*, replace nonumbers nogaps noomit nobase label r2 ///
  cells(b(fmt(%9.3f) star) se(par)) star(* 0.10 ** 0.05 *** 0.01)  ///
  coeflabels(1.mostvoted "Most Voted Party" svote "Share of Votes" 1.women_leader "Woman Leader" 1.mostvoted#1.women_leader "Most Voted * Woman Leader") ///
  addnotes(Standard errors in parentheses. *p<.1; **p<.05; ***p<.01.)


  

**Figure C1: RD plot of the most voted advantage  

use main_long.dta, clear
  
quietly rdrobust mayor diff if absoluta==0, all
rdplot mayor diff if absoluta==0 & inrange(diff,-e(h_l),e(h_r)), ///
   binselect(esmv) kernel(triangular) h(`e(h_l)' `e(h_r)') p(1) ///
   graph_options(legend(off) xlabel(-.06(.01).06) ylabel(0(.1)1) ///
   ytitle("Pr(Mayor Party = 1)") xtitle("Margin of Victory", height(5))) ///
   scheme(plotplain)

  
  


**Table D1 [TRANSPOSED]: Discontinuities in pretreatment covariates (Local linear regression estimates)

use main_short.dta, clear

quietly estimates clear

*Number of parties represented
quietly rdrobust numparties fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal01
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Number of seats in local council
quietly rdrobust total_seat fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal02
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Turnout
quietly rdrobust turnout fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal03
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Population (absolute)
quietly rdrobust pop fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal04
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Population (log)
quietly rdrobust logpop fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal05
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Population density
quietly rdrobust density fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal06
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Total pre-election expenditures per cap.
quietly rdrobust htotalexp_pc fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal07
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Unemployment rate (2001)
quietly rdrobust tasaparo2059 fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal08
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Tertiary sector share (2001)
quietly rdrobust pesodelsectorterciario fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal09
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Municipal average education level (2001)
quietly rdrobust nivelmediodeestudiosenelgrupodee fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal10
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Municipal average age (2001)
quietly rdrobust edadmediapersonas fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal11
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Share of non-EU immigrants (2001)
quietly rdrobust extranjerosnocomunitarios fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal12
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Coastline municipality
quietly rdrobust coast fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal13
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Distance to the coast
quietly rdrobust dist_coast fwl if absoluta==0,  h(.091) b(.157)
	quietly estimates store bal14
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Table
esttab bal*, replace nonumbers nogaps ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "RD Estimate") collabels("" "") ///
  stats(pcl en n, labels("P-value" "Effective N" "N") fmt(%9.3f 0 0)) ///
  mlabels("Number of parties represented" ///
  "Number of seats in local council" ///
  "Turnout" ///
  "Population (raw)" ///
  "Population (log)" ///
  "Population density" ///
  "Total pre-election expenditures per capita" ///
  "Unemployment rate (2001)" ///
  "Municipal average level of education (2001)" ///
  "Municipal average age (2001)" ///
  "Share of non-EU immigrants in the municipality (2001)" ///
  "Coastline municipality" ///
  "Distance to the coast") ///
  addnotes(Bandwidth is the optimal in the main analyses: .091)


 
**Figure D1: Continuity of the forcing variable

use main_short.dta, clear

*Left plot
histogram fwl if absoluta==0, freq start(-.5) width(.05) color(gs3) ///
  addplot(histogram fwl if absoluta==0, freq start(-.5) width(.025) color(gs7) || ///
  histogram fwl if absoluta==0, freq start(-.5) width(.01)  xlabel(-.5(.05).5) ylabel(0(50)400) ///
  color(gs11) xline(0,) xtitle("Woman's margin of victory") legend(order(1 "Bin width = 5%" 2 "Bin width = 2.5%" 3 "Bin width = 1%") position (6) row(1))) ///
  scheme(plotplain)

*Right plot
DCdensity fwl if absoluta==0, breakpoint(0) generate(Xj Yj r0 fhat se_fhat)
	drop Xj Yj r0 fhat se_fhat




**Table E1: Robust bias corrected inference

use main_short.dta, clear

quietly estimates clear

*All parties
quietly rdrobust mayorwinner fwl if absoluta==0, all
	quietly estimates store robbias_all
	quietly estadd scalar prb = e(pv_rb)
	quietly estadd scalar bwrb = e(b_l)
	quietly estadd scalar enb =  e(N_b_l) +  e(N_b_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03, all 
	quietly estimates store robbias_third
	quietly estadd scalar prb = e(pv_rb)
	quietly estadd scalar bwrb = e(b_l)
	quietly estadd scalar enb =  e(N_b_l) +  e(N_b_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties & gender-mixed
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & gendermixed==1, all
	quietly estimates store robbias_third_gm
	quietly estadd scalar prb = e(pv_rb)
	quietly estadd scalar bwrb = e(b_l)
	quietly estadd scalar enb =  e(N_b_l) +  e(N_b_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Table
esttab robbias_*, replace nonumbers nogaps ///
  drop(Conventional Bias-corrected) ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "Female leader") collabels("" "") ///
  stats(prb bwrb enb n, labels("P-value" "Bandwidth" "Effective N" "N") fmt(%9.3f %9.3f 0 0)) ///
  mlabels("All parties" "No 3rd parties" "No 3rd parties \& gender-mixed") ///
  addnotes(Standard errors in parentheses.)




**Table E2: Multiple kernels for observations within the bandwidth

use main_short.dta, clear

quietly estimates clear

*Kernel epanechnikov: All parties
quietly rdrobust mayorwinner fwl if absoluta==0, kernel(epa) h(.091) b(.157)
	quietly estimates store k_epa_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Kernel epanechnikov: No 3rd parties
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03, kernel(epa) h(.095) b(.162)
	quietly estimates store k_epa_third
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Kernel epanechnikov: No 3rd parties & gender-mixed
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & gendermixed==1, kernel(epa) h(.061) b(.120)
	quietly estimates store k_epa_third_gm
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Kernel uniform: All parties
quietly rdrobust mayorwinner fwl if absoluta==0, kernel(uni) h(.091) b(.157)
	quietly estimates store k_uni_all
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Kernel uniform: No 3rd parties
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03, kernel(uni) h(.095) b(.162)
	quietly estimates store k_uni_third
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Kernel uniform: No 3rd parties & gender-mixed
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & gendermixed==1, kernel(uni) h(.061) b(.120)
	quietly estimates store k_uni_third_gm
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Table 
esttab k_*, replace nonumbers nogaps ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "Female leader") collabels("") mgroups("Kernel epanechnikov" "Kernel uniform", pattern(1 0 0 1 0 0) span) ///
  stats(pcl bwcl en n, labels("P-value" "Bandwidth" "Effective N" "N") fmt(%9.3f %9.3f 0 0)) ///
  mlabels("All parties" "No 3rd parties" "No 3rd parties \& gender-mixed") ///
  addnotes(Standard errors in parentheses.)




**Figure E1: RD plot of the most voted advantage

use main_short.dta, clear

quietly{
	gen above=(fwl>=0)
	gen fwlXabove=fwl*above

	quietly estimates clear

	forval b=3(1)20 {
		di `b'/100
		capture gen weight_`b'=max(0,(`b'/100)-abs(fwl))
		reg mayorwinner fwl above fwlXabove if absoluta==0 [pw=weight_`b'], vce(robust)
		quietly estimates store bw`b'
	}

	quietly coefplot bw3 bw4 bw5 bw6 bw7 bw8 bw9 bw10 bw11 bw12 bw13 bw14 bw15 bw16 bw17 bw18 bw19 bw20, nodraw ///
		keep(above) vertical yline(0,) legend(off) ciopts(lcolor(black) recast(rcap)) gen(_c) replace

	keep _c*
	gen bw = .
	local bw_sizes 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  
	forvalues i = 1/18{
		local bw_value: word `i' of `bw_sizes'
		replace bw = `bw_value' if [_n] == `i'
	}
}
scatter _cb bw, mc(black) || rcap _cul1 _cll1 bw, lc(black) ||, ///
	xlabel(3(1)20) ylabel(-.8(.1).2) yline(0, lp(dash)) legend(off) ///
	xtitle("RD bandwidth (%)") xscale(titlegap(*5)) ///
	ytitle("RD estimate (95% CI)") yscale(titlegap(*-25)) ///
	scheme(plotplain)




**Figure E2: RD plot of the most voted advantage

use main_short.dta, clear

quietly{
	gen fwlplac=fwl+.10
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_m10
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl+.08
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_m8
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl+.06
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_m6
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl+.04
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_m4
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl+.02
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_m2
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl+0
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_0
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl-.02
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_p2
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl-.04
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_p4
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl-.06
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_p6
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl+-.08
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_p8
	drop fwlplac above fwlplacXabove weight

	gen fwlplac=fwl-.10
	gen above=(fwlplac>=0)
	gen fwlplacXabove=fwlplac*above
	rdrobust mayorwinner fwlplac if absoluta==0
	local bw `e(h_l)'
	gen weight=max(0,`bw'-abs(fwlplac))
	reg mayorwinner fwlplac above fwlplacXabove if absoluta==0 [pw=weight], vce(robust)
	quietly estimates store cutoff_p10
	drop fwlplac above fwlplacXabove weight

	coefplot cutoff_m10 cutoff_m8 cutoff_m6 cutoff_m4 cutoff_m2 cutoff_0 cutoff_p2 cutoff_p4 cutoff_p6 cutoff_p8 cutoff_p10, nodraw ///
		keep(above) vertical yline(0,) legend(off) ciopts(lcolor(black) recast(rcap)) gen(_c) replace

	keep _c*
	gen cutoff = .
	local cutoff_thresholds -.10 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .10
	forvalues i = 1/11{
		local cutoff_value: word `i' of `cutoff_thresholds'
		replace cutoff = `cutoff_value' if [_n] == `i'
	}
}

scatter _cb cutoff, mc(black) || rcap _cul1 _cll1 cutoff, lc(black) ||, ///
	xline(0, lp(shortdash)) xlabel(-.10(.02).10) ylabel(-.5(.1).5) yline(0, lp(dash)) legend(off) ///
	xtitle("Placebo cutoff") xscale(titlegap(*5)) ///
	ytitle("RD estimate (95% CI)") yscale(titlegap(*-25)) ///
	scheme(plotplain)




**Table E3: The effect of gender quotas

use main_short.dta, clear

quietly estimates clear

*All parties: 2003
quietly rdrobust mayorwinner fwl if absoluta==0 & year==2003,  h(.091) b(.157)
	quietly estimates store quota_all_03
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*All parties: 2003
quietly rdrobust mayorwinner fwl if absoluta==0 & year==2007,  h(.091) b(.157)
	quietly estimates store quota_all_07
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties: 2003
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & year==2003,  h(.091) b(.157)
	quietly estimates store quota_third_03
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties: 2007
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & year==2007,  h(.091) b(.157)
	quietly estimates store quota_third_07
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties & gender-mixed: 2003
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & gendermixed==1 & year==2003,  h(.091) b(.157)
	quietly estimates store quota_third_gm_03
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*No 3rd parties & gender-mixed: 2007
quietly rdrobust mayorwinner fwl if absoluta==0 & diff_second_third>.03 & gendermixed==1 & year==2007,  h(.091) b(.157)
	quietly estimates store quota_third_gm_07
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Table
esttab quota_all_03 quota_all_07 quota_third_03 quota_third_07 quota_third_gm_03 quota_third_gm_07, replace nonumbers nogaps ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "Female leader") collabels("" "") mgroups("All parties" "No 3rd parties" "No 3rd parties \& gender-mixed", pattern(1 0 1 0 1 0) span) ///
  stats(pcl bwcl en n, labels("P-value" "Bandwidth" "Effective N" "N") fmt(%9.3f %9.3f 0 0)) ///
  mlabels("2003" "2007" "2003" "2007" "2003" "2007") ///
  addnotes(Standard errors in parentheses)




**Figure E3: RD estimate difference 2003-2007: Contrasts

use main_short.dta, clear

quietly gen weight_091=max(0,0.091-abs(fwl))
quietly gen weight_095=max(0,0.095-abs(fwl))
quietly gen weight_061=max(0,0.061-abs(fwl))

*Top-left plot: Main results
quietly{
	reg mayorwinner c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(main_y1, replace)
	reg mayorwinner c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.095,.095) & diff_second_third>.03 [pw=weight_095]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(main_y2, replace)
	reg mayorwinner c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.061,.061) & diff_second_third>.03 & gendermixed==1 [pw=weight_061]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(main_y3, replace)
	combomarginsplot main_y3 main_y2 main_y1, nodraw ///
	 horiz recast(scatter) ///
	 xline(0) ///
	 labels( ///
	 "{stMono:No 3rd parties & mixed}" ///
	 "{stMono:        No 3rd parties}" ///
	 "{stMono:           All parties}" ///
	 ) ///
	 ylabel(, labsize(vsmall)) yscale(range(0.8 3.2)) ///
	 xlabel(-1(.2)1, labsize(vsmall)) xscale(titlegap(*5)) ///
	 title("Main results") ytitle("") xtitle("Contrast of discontinuity 2007 vs 2003", size(small)) ///
	 scheme(plotplain) ///
	 saving(main_y, replace)
}
 
*Top-right plot: Other outcomes
quietly{
	reg firstgov c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(other_y1, replace)
	reg runnerupgov c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(other_y2, replace)
	reg thirdmoregov c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(other_y3, replace)
	reg mayorsecond c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(other_y4, replace)
	reg mayorthirdormore c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(other_y5, replace)
	combomarginsplot other_y5 other_y4 other_y3 other_y2 other_y1, nodraw ///
	 horiz recast(scatter) ///
	 xline(0) ///
	 labels( ///
	 "{stMono:            Mayor 3rd+}" ///
	 "{stMono:             Mayor 2nd}" ///
	 "{stMono:          3rd+ in gov.}" ///
	 "{stMono:           2nd in gov.}" ///
	 "{stMono:           1st in gov.}" ///
	 ) ///
	 ylabel(, labsize(vsmall)) yscale(range(0.8 5.2)) ///
	 xlabel(-1(.2)1, labsize(vsmall)) xscale(titlegap(*5)) ///
	 title("Other outcomes") ytitle("") xtitle("Contrast of discontinuity 2007 vs 2003", size(small)) ///
	 scheme(plotplain) ///
	 saving(other_y, replace)
}
 
*Bottom-left plot: Mechanisms
quietly{
	foreach v of varlist agefirst edufirst incumbent ideology pp psoe other {
		qui reg mayorwinner c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]    
		qui summ `v' if e(sample)
		gen `v'_01 = (`v' - r(min)) / (r(max) - r(min)) if e(sample)
	}
	reg agefirst_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(mec_y1, replace)
	reg edufirst_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(mec_y2, replace)
	reg incumbent_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(mec_y3, replace)
	reg ideology_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(mec_y4, replace)
	reg pp_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(mec_y5, replace)
	reg psoe_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(mec_y6, replace)
	reg other_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(mec_y7, replace)
	combomarginsplot mec_y7 mec_y6 mec_y5 mec_y4 mec_y3 mec_y2 mec_y1, nodraw ///
	 horiz recast(scatter) ///
	 xline(0) ///
	 labels( ///
	 "{stMono:          MVP = Others}" ///
	 "{stMono:            MVP = PSOE}" ///
	 "{stMono:              MVP = PP}" ///
	 "{stMono:        MVP left-right}" ///
	 "{stMono:         MVP Incumbent}" ///
	 "{stMono:     MVP Av. education}" ///
	 "{stMono:           MVP Av. age}" ///
	 ) ///
	 ylabel(, labsize(vsmall)) yscale(range(0.8 5.2)) ///
	 xlabel(-1(.2)1, labsize(vsmall)) xscale(titlegap(*5)) ///
	 title("Mechanisms") ytitle("") xtitle("Contrast of discontinuity 2007 vs 2003", size(small)) ///
	 saving(mec_y, replace) ///
	 scheme(plotplain)
}

*Bottom-right panel: Covariate balance
quietly{
	rename nivelmediodeestudiosenelgrupodee nivelmedioestudios
	foreach v of varlist numparties total_seat turnout pop logpop density htotalexp_pc tasaparo2059 pesodelsectorterciario nivelmedioestudios edadmediapersona extranjerosnocomunitarios coast dist_coast {
		qui reg mayorwinner c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]    
		qui summ `v' if e(sample)
		gen `v'_01 = (`v' - r(min)) / (r(max) - r(min)) if e(sample)
	}
	reg numparties_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y1, replace)
	reg total_seat_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y2, replace)
	reg turnout_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y3, replace)
	reg pop_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y4, replace)
	reg logpop_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y5, replace)
	reg density_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y6, replace)
	reg htotalexp_pc_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y7, replace)
	reg tasaparo2059_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y8, replace)
	reg pesodelsectorterciario_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y9, replace)
	reg nivelmedioestudios_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y10, replace)
	reg edadmediapersonas_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y11, replace)
	reg extranjerosnocomunitarios_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y12, replace)
	reg coast_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y13, replace)
	reg dist_coast_01 c.fwl##i.womanfirst##i.year if absoluta==0 & inrange(diff,-.091,.091) [pw=weight_091]
		margins , dydx(womanfirst) at(fwl=0 year=(2003 2007)) contrast(atcontrast(r._at) pv) saving(bal_y14, replace)
	combomarginsplot bal_y14 bal_y13 bal_y12 bal_y11 bal_y10 bal_y9 bal_y8 bal_y7 bal_y6 bal_y5 bal_y4 bal_y3 bal_y2 bal_y1, nodraw ///
	 horiz recast(scatter) ///
	 xline(0) ///
	 labels( ///
	 "{stMono:           Dist. Coast}" ///
	 "{stMono:             Coastline}" ///
	 "{stMono:     Non-EU immigrants}" ///
	 "{stMono:               Av. age}" ///
	 "{stMono:         Av. education}" ///
	 "{stMono:       Tertiary sector}" ///
	 "{stMono:          Unemployment}" ///
	 "{stMono: Pre-election spending}" ///
	 "{stMono:    Population density}" ///
	 "{stMono:      Population (log)}" ///
	 "{stMono:      Population (raw)}" ///
	 "{stMono:               Turnout}" ///
	 "{stMono:           N. of seats}" ///
	 "{stMono:         N. of parties}" ///
	 ) ///
	 ylabel(, labsize(vsmall)) yscale(range(0.8 5.2)) ///
	 xlabel(-1(.2)1, labsize(vsmall)) xscale(titlegap(*5)) ///
	 title("Covariate balance") ytitle("") xtitle("Contrast of discontinuity 2007 vs 2003", size(small)) ///
	 saving(bal_y, replace) ///
	 scheme(plotplain)
}

*Graph
graph combine main_y.gph other_y.gph mec_y.gph bal_y.gph, xcommon imargin(tiny) ///
	scheme(plotplain)




**Table G1: Heterogeneous effect by gender of the leader of parties ranked third

use main_short.dta, clear

quietly estimates clear

*All cases
quietly rdrobust mayorthird fwl if absoluta==0, h(.091)
	quietly estimates store third1
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*3rd female leader
quietly rdrobust mayorthird fwl if absoluta==0 & womanthird==1, h(.091)
	quietly estimates store third2
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*3rd male leader
quietly rdrobust mayorthird fwl if absoluta==0 & womanthird==0, h(.091)
	quietly estimates store third3
	quietly estadd scalar pcl = e(pv_cl)
	quietly estadd scalar bwcl = e(h_l)
	quietly estadd scalar en =  e(N_h_l) +  e(N_h_r)
	quietly estadd scalar n = e(N_l) + e(N_r)

*Table
esttab third*, replace nonumbers nogaps ///
  cells(b(fmt(%9.3f)) se(par)) varlabels(RD_Estimate "Female leader") collabels("" "") ///
  stats(pcl bwcl en n, labels("P-value" "Bandwidth" "Effective N" "N") fmt(%9.3f %9.3f 0 0)) ///
  mlabels("All cases" "3rd female leader" "3rd male leader") ///
  addnotes(Standard errors in parentheses)



